package Year22_Month06.day27;

import java.util.Scanner;

public class 排序子序列 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        int[] arr = new int[length];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }
        int count = 0;//用来定义排序子序列个数
        int i = 1;//定义下标
        while(i < length){
            if(arr[i] > arr[i - 1]){//非递减
               while(i < length && arr[i] >= arr[i - 1]) {
                   i++;
               }
               i++;
               count++;
            }else if(i < length && arr[i] == arr[i + 1]){
                i++;
            } else{//非递增
                while(i < length&& arr[i] <= arr[i - 1]){
                    i++;
                }
                count++;
            }
        }
        System.out.println(count);
    }
}
